package com.dt.dubai.core.pay.alipay.controller;

import com.alipay.api.AlipayApiException;
import com.dt.dubai.core.pay.alipay.entity.bean.AlipayBean;
import com.dt.dubai.core.pay.alipay.service.ser.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 订单接口
 *
 * @author Louis
 * @date Dec 12, 2018
 */
@Controller
@RequestMapping(value = "/order")
public class OrderController {

    @Autowired
    private PayService payService;

    /**
     * 阿里支付
     *
     * @param outTradeNo
     * @param subject
     * @param totalAmount
     * @param body
     * @return
     * @throws AlipayApiException
     */
    @RequestMapping(value = "/alipay",method = RequestMethod.POST)
    @ResponseBody
    public String alipay(String outTradeNo, String subject, String totalAmount, String body) throws AlipayApiException {
        AlipayBean alipayBean = new AlipayBean();
        alipayBean.setOut_trade_no(outTradeNo);
        alipayBean.setSubject(subject);
        alipayBean.setTotal_amount(totalAmount);
        alipayBean.setBody(body);
        return payService.aliPay(alipayBean);
    }
}